package analyzemytime.datamodel;

import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.joda.time.DateTime;

public class Utils {
	public static DateTime parseDate(String date){
		Pattern pattern = Pattern.compile("(\\d{1,2}).(\\d{2}).(\\d{4})");
		Matcher matcher = pattern.matcher(date);
		DateTime dateTime = new DateTime();
		if (matcher.matches()) {
			  int dayOfMonth   = Integer.parseInt(matcher.group(1));
			  int monthOfYear = Integer.parseInt(matcher.group(2));
			  int year  = Integer.parseInt(matcher.group(3));
			  dateTime = new DateTime(year,monthOfYear,dayOfMonth,0,0);
			 
		}
		return dateTime;
	}
	
	public static DateTime formatDateToDateTime(Date date)//As of JDK 1.1 Deprecated :)
	{
		DateTime dateTime = new DateTime(date);
		return dateTime;
	}
}
